<?php

namespace app\app\validate\order;

use app\common\model\Bill;
use think\Validate;

class BillValidate extends Validate
{
    protected $rule = [
        'type' => 'require|checkType',
        'money' => 'require|>:0'
    ];


    protected $message = [
        'type.require' => 'Please select a type',
        'money.require' => 'Please enter the amount',
        'money.>' => 'The amount cannot be less than 0'
    ];

    protected $scene = [
        'add' => ['type', 'money'],
    ];


    /**
     * Notes: 状态类型检测
     * User: chenLei
     * Date: 8/15/25
     * @param $value
     * @param $rule
     * @param $data
     * @return string|true
     */
    public function checkType($value, $rule, $data)
    {

        $type = Bill::TYPE;
        if (!in_array($value, $type)) {
            return 'Please select a type';
        }
        return true;
    }
}